package BusinessLogic;

import java.util.ArrayList;

import Data.GoodData;
import Data.SaleRecordData;
import Data.UserData;

public class SaleController implements ISaleController{

	private SaleModel ism;
	
	public SaleModel getISaleModel(){
		return ism;
	}
	
	public void setISaleModel(SaleModel iSm){
		ism = iSm;
	}
	
	public SaleController(){
		ism = new SaleModel();
	}
	
	public UserData getUserInformationControl(int UserID){
		return ism.getUserInformation(UserID);
	}
	
	public String searchUserInformationByIDControl(int ID){
		return ism.searchUserInformationByID(ID);
	}
	
	public String searchGoodInformationByIDControl(int ID){
		return ism.searchGoodInformationByID(ID);
	}
	
	public GoodData getGoodInformationControl(int GoodID){
		return ism.getGoodInformation(GoodID);
	}
	
	public boolean addItemControl(int id,String name,double price,int num,double spepri,String date){
		try{
			return ism.addItem(id, name, price, num,spepri,date);
		}catch(Exception e){
			return false;
		}
	}
	
	public boolean removeItemControl(String goodID){
		try{		
    		return ism.removeItem(goodID);
    	}catch(Exception e){
    		return false;
    	}  
	}
	
	public double buyControl(){
		return ism.buy();
	}
	
	public boolean startUpdateControl(){
	 	try{		
    		return ism.startUpdate();
    	}catch(Exception e){
    		return false;
    	}
    	
    }
	
	public boolean checkSpecialTimeControl(String startTime,String endTime){
		 return ism.checkSpecialTime(startTime, endTime);
	}
	
	public String getGoodDescriptionByIDControl(int ID){
		return ism.getGoodDescriptionByID(ID);
	}
	
	public double getGoodPriceByIDControl(int ID){
		return ism.getGoodPriceByID(ID);
	}
	
	public double getGoodSpecialPriceByIDControl(int ID){
		return ism.getGoodSpecialPriceByID(ID);
	}
	
	public String getGoodSpecialTimeStartByIDControl(int ID){
		return ism.getGoodSpecialTimeStartByID(ID);
	}
	
	public String getGoodSpecialTimeEndByIDControl(int ID){
		return ism.getGoodSpecialTimeEndByID(ID);
	}
	public double getGoodNumberByIDControl(int ID){
		return ism.getGoodNumberByID(ID);
	}
	
	public String getUserNameByIDControl(int ID){
		return ism.getUserNameByID(ID);
	}
	
	public String getUserPasswordByIDControl(int ID){
		return ism.getUserPasswordByID(ID);
	}
	
	public int getNextSaleIDControl(){
		return ism.getNextSaleID();
	}

	@Override
	public ArrayList<SaleRecordData> readSaleRecordDataBySaleIDControl(int ID) {
		// TODO Auto-generated method stub
		return ism.readSaleRecordDataBySaleID(ID);
	}
}
